let app = new Vue({
    el: '#app',
    data: {
        examPaperResult: JSON.parse(sessionStorage.getItem('examPaperResultView2')),  // 存储试卷结果信息
        paperQuestions: [],  // 存储试题数据
        singleCount: 0,    // 记录单选题数量
        multipleCount: 0,  // 记录多选题数量
        judgeCount: 0     // 记录判断题数量        

    },
    created() {
        // 根据试卷结果的编号查询错题信息
        $.ajax({
            url: 'http://localhost:8080/errorQuestion/selectByExamPaperResultId',
            type: 'post',
            data: { examPaperResultId: this.examPaperResult.examPaperResultId },
            success: function (vo) {
                if (vo.code == 200) {
                    app.paperQuestions = vo.data;
                    app.singleCount = vo.singleCount;
                    app.multipleCount = vo.multipleCount;
                    app.judgeCount = vo.judgeCount;
                    // console.log(app.paperQuestions);
                    // console.log(app.singleCount);
                    // console.log(app.multipleCount);
                    // console.log(app.judgeCount);

                }
            }
        });
    },
    updated() {
        layui.use(['form', 'rate'], function () {
            let form = layui.form;
            let rate = layui.rate;
            form.render();

            layui.each(app.paperQuestions, function (index, item) {
                let difficult = item.paperQuestionInfo.difficult;

                rate.render({
                    elem: '#rate' + index,
                    value: difficult,
                    readonly: true
                });

            })

        });
    },
    filters: {
        dateFormat: function (result) {
            var h = Math.floor(result / 3600) ;
            var m = Math.floor((result / 60 % 60));
            var s = Math.floor((result % 60));
            if (h == 0) {
                result = m + "分" + s + "秒";
            } else {
                result = h + '时' + m + "分" + s + "秒"
            }
            return result;
        }
    }

});











